﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Lesson14 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Scrollbar bar = this.gameObject.GetComponent<Scrollbar>();
        Debug.LogFormat("bar value:{0} size:{1}", bar.value, bar.size);

        #region 监听事件
        bar.onValueChanged.AddListener((value)=> {
            //Debug.LogFormat("代码监听 value:{0}", value);
        });
        ////添加监听
        //bar.onValueChanged.AddListener(ChangeScrollBar);
        ////删除监听
        //bar.onValueChanged.RemoveListener(ChangeScrollBar);
        ////删除所有监听
        //bar.onValueChanged.RemoveAllListeners();
        #endregion
    }

    public void ChangeScrollBar(float value)
    {
        Debug.LogFormat("ChangeScrollBar:{0}", value);
    }
}
